﻿using UnityEngine;
namespace SG
{
    public class KeyboardMgr : MgrCore
    {
        #region
        private static KeyboardMgr m_instance;
        public static KeyboardMgr Instance()
        {
            if (m_instance == null)
                m_instance = new KeyboardMgr();// InstanceHelper.Singleton<KeyboardMgr>();// obj.GetOrAddComponent<SceneMgr>();
            return m_instance;

        }
        #endregion
        bool m_bUsed = false;

        public override void DoUpdate()
        {

            Vector2 end = Vector2.zero;

            if (Input.GetKey(KeyCode.W))
            {
                end.y = 1;
                m_bUsed = true;
            }
            if (Input.GetKey(KeyCode.S))
            {
                end.y = -1;
                m_bUsed = true;
            }
            if (Input.GetKey(KeyCode.A))
            {
                end.x = -1;
                m_bUsed = true;
            }
            if (Input.GetKey(KeyCode.D))
            {
                end.x = 1;
                m_bUsed = true;
            }
            if (end == Vector2.zero && m_bUsed)
            {
                m_bUsed = false;
                EventParamCommon cmd = new EventParamCommon();
                cmd.AddDataVector("offset", Vector3.zero);

                return;
            }
            if (m_bUsed)
            {
                EventParamCommon cmd = new EventParamCommon();
                cmd.AddDataVector("offset", end);

            }

        }
    }
}